<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>滚滚向前投票助手</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1200">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="/dist/plugins/fixedTable/fixed-table.css"/>
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=39cd89cd">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        .noData {
            padding-top: 60px;
            font-size: 16px;
            color: #ddd;
            text-align: center;
        }
        .tijiaoBtn {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 50px;
            line-height: 50px;
            background: #228bee;
            color: #fff;
            text-align: center;
            font-weight: bold;
            font-size: 16px;
            z-index: 9999999;
        }
        .tijiaoBtn {
            position: fixed;
            bottom: 50px;
            left: 47%;
            width: 100px;
            height: 35px;
            line-height: 35px;
            background: #228bee;
            color: #fff;
            text-align: center;
            font-weight: bold;
            font-size: 16px;
        }
        .visitingBox {
            background: #fff;
            padding-bottom: 50px;
        }
        .item .center{
            margin-right:60px;
            display:table-cell;
            vertical-align:middle;
        }
        .item {
            height: 44px;
            line-height: 44px;
            font-size:14px;
            position:relative;
            border-bottom:1px solid rgb(238, 238, 238);
            display:table;
            width:100%;
            overflow:hidden;
        }

        .item .xh{
            position: absolute;
            left:0;
            top:0;
            width: 40px;
            text-align: center;
            height: 44px;
            line-height: 44px;
            text-align:center;
            font-size:12px;
        }
        .item .title {
            margin-left: 40px;
            vertical-align:middle;
            display:table-cell;
            float:none;
            margin-right: 145px;
            line-height:18px;
            max-height:45px;
            overflow:hidden;
            text-overflow:ellipsis;
            display:-webkit-box;
            -webkit-box-orient:vertical;
            -webkit-line-clamp:2;
            visibility:inherit;
            margin-top: 2px;

        }

        .item .time {
            color:#aaa;
            position:absolute;
            width:80px;
            right:0px;
            top:0px;
            height: 44px;
            line-height: 44px;
            text-align:center;
            font-size:12px;
        }
        .item .createUser {
            color:#aaa;
            position:absolute;
            width:36px;
            top:0px;
            height: 44px;
            line-height: 44px;
            font-size:12px;
            text-align: justify;
            right: 92px;
        }
        .item .createUser:after { content: " "; display: inline-block; width: 100%;}
        .fixed-table_body tr:nth-of-type(odd){
            background: #F9F9F9;
        }
        .tableTitle{
            text-align: center;
        }
        .content {
            padding: 8px 8px 0 8px;
        }
    </style>
</head>
<body>

<section class="content" id="app" v-cloak>
    <iframe id="ifExprot" style="width:0px;height:0px;display: none;" frameborder="0"></iframe>
    <div class="oaLoad">
        <div class="loadGif" id="areaProgress"></div>
    </div>
    <input type="text" placeholder="关键字" class="form-control pull-left input-sm"
           style="width: 200px; " v-model="key" id="txtParent">
    <button type="button" class="btn oaBtn btn-sm pull-left"
            style="margin-left: 10px;min-width:10px;width:50px;" @click="search()">
        查询
    </button>
    <input type="button" value="新建投票" class="btn oaBtn btn-sm pull-right" @click="getDetail('add','')"
           style="min-width:10px;width:70px;text-align: center">
    <div class="box-body no-padding fixed-table-box" style="overflow: auto;margin-top:10px;display: inline-block; " id="scrollDiv">
        <table class="fixed-table_body table-hover"  cellspacing="0" cellpadding="0" border="0" style="text-align: center;width: 100%;">
            <thead >
            <tr>
                <td class="tableTitle" style="width: 50px;height: 24px;text-align: center;">序号</td>
                <td class="tableTitle" style="text-align: center;">投票内容</td>
                <td class="tableTitle" style="width: 80px;text-align: center;">创建人</td>
                <td class="tableTitle" style="width: 60px;text-align: center;">状态</td>
                <td class="tableTitle"style="width: 70px;text-align: center;">操作</td>
                <td class='tableTitle' style="width: 17px"></td>
            </tr>
            </thead>
        </table>
        <div class="fixed-table_body-wraper iframeFixed"  style="overflow-y: scroll;">
            <table class="fixed-table_body table-hover"  cellspacing="0" cellpadding="0" border="0" style="text-align: center;width: 100%;">
                <tbody>
                <template v-if="list.length>0">
                    <tr v-for="(item,i) in list" style="height: 24px">
                        <!--<td style="width:20px;">
                            <input type="checkbox" enabled="isEnable(item)" v-model="item.checked"/>
                        </td>-->
                        <td style="width: 50px;height: 24px;text-align: center;">{{i+1}}</td>
                        <td style="text-align: left;">{{item.title}}</td>
                        <td style="width:80px;text-align: center;">{{item.createUserName}}</td>
                        <td style="width: 60px;text-align: center;">
                            <!--状态显示   auditFlag==='-4' 新建 被驳回 -->
                            <template v-if="item.auditFlag==='-4'">
                                <div class="tjResult"   style="color:#333;">新建投票<a class="bz" style="color:red;">已驳回</a></div>
                            </template>

                            <!--状态显示   auditFlag==='-3' 新建 待审核 -->
                            <template v-if="item.auditFlag==='-3'">
                                <div class="tjResult"   style="color:#333;">新建投票 <a class="bz" style="color:red;">待审核</a></div>
                            </template>

                            <!--状态显示   auditFlag==='-2' 新建 未全部上传附件 -->
                            <template v-if="item.auditFlag==='-2'">
                                <!--未上传投票人员--》点击前往上传附件-->
                                <template v-if="(item.noFjNames.indexOf(userInfo.name)>-1)">
                                    <div class="tjResult"   style="color:red;">未上传</div>

                                </template>
                                <!--所有人未上传完成&&当前登录人为创建人--》点击前往修改页面-->
                                <template v-else-if="item.createUserId==userId">
                                    <div class="tjResult"   style="color:red;">上传中</div>
                                </template>
                                <template v-else>
                                    <!--其余人-->
                                    <div class="tjResult" style="color:red;">上传中</div>
                                </template>

                            </template>

                            <!--状态显示   auditFlag==='-1' 投票中 -->
                            <template v-if="item.auditFlag==='-1'">
                                <!--所有人未上传完成&&当前登录人为创建人--》点击前往修改页面-->
                                    <div class="tjResult"    >投票中</div>
                            </template>

                            <!--状态显示   auditFlag==='0' 审核中 -->
                            <template v-if="item.auditFlag==='0'">
                                <!--未结束投票-->
                                <template v-if="compareDate(item.endTime)">
                                    <div class="tjResult" >投票中</div>
                                </template>
                                <!--已结束投票-->
                                <template v-else>
                                    <div class="tjResult"  style="color:#333;">投票结果 <a class="bz" style="color:red;">待审核</a></div>
                                </template>
                            </template>

                            <!--状态显示   auditFlag==='2' 已驳回 -->
                            <template v-if="item.auditFlag==='2'">
                                <div class="tjResult" >投票结果 <a class="bz">已驳回</a></div>
                            </template>

                            <!--状态显示   auditFlag==='1' 已通过 -->
                            <template v-if="item.auditFlag==='1'">
                                <div class="tjResult">已通过</div>
                            </template>
                        </td>
                        <td style="width: 70px;text-align: center;">
                            <a href="javascript:void(0);" @click="getDetail('edit',item.id)"
                               style="color:#2a8cec;cursor: pointer;text-align: center"
                               v-if="isCheck('修改',item.auditFlag)&&item.createUserName==userInfo.name&&item.auditFlag=='-4'">修改</a>
                            <a href="javascript:void(0);" @click="getDetail('shenHe',item.id)"
                               style="color:#2a8cec;cursor: pointer;text-align: center"
                               v-else-if="isCheck('修改',item.auditFlag)&&item.currentAuditorName==userInfo.name&&item.auditFlag=='-3'">审核</a>
                            <!--<a href="javascript:void(0);" @click="getResult(item.id,item.auditFlag)"
                               style="color:#2a8cec;cursor: pointer;text-align: center"
                               v-else-if="isCheck('修改',item.auditFlag)&&item.createUserName==userInfo.name&&item.auditFlag=='0'">审核</a>-->
                            <a v-else-if="isCheck('修改',item.auditFlag)&&item.currentAuditorName==userInfo.name" style="text-align: center;color: #CCCCCC"
                              >审核</a>
                            <a style="text-align: center;color: #CCCCCC"
                               v-else>修改</a>
                            <a href="javascript:void(0);" @click="getDetail('look',item.id)"
                               style="color:#2a8cec;cursor: pointer;text-align: center"
                              >查看</a>
                           <!-- <a style="text-align: center;color: #CCCCCC"
                               v-else>查看</a>-->
                            <a href="javascript:void(0);" @click="getResult(item.id,item.auditFlag)"
                               style="color:#2a8cec;cursor: pointer;text-align: center"
                               v-if="isCheck('投票结果',item.auditFlag)">投票结果</a>
                            <a style="text-align: center;color: #CCCCCC"
                               v-else>投票结果</a>
                        </td>
                    </tr>
                </template>
                <tr v-else>
                    <td colspan="5" style="text-align: center;width: 100%;">暂无投票内容</td>
                </tr>


                </tbody>
            </table>
        </div>

    </div>
    <div class="oa-pager text-center" style="margin-bottom: 5px;position: absolute;bottom:0px;left: 41%">
        共
        <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
        <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
        <span class="oa-pager-button" id="first">首页</span>
        <span class="oa-pager-button" id="prev">上一页</span>
        <span class="oa-pager-button" id="next">下一页</span>
        <span class="oa-pager-button" id="last">尾页</span>
    </div>
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=558d0414"></script>

<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            title:"",
            userInfo:{},
            userId:getCurrentUser().id,
            date: "",
            list: [],
            isMore: false,
            swiper:"",
            mySwiper:"",
            rightOp:[],
            key: ''

        },
        methods: {
            getDetail:function (pageType,item,auditFlag) {
                var that=this;
                if(pageType=='add'){
                    top.closeTabByPageId("detail");
                    top.addTabs({
                        id: 'detail',
                        title: '投票详情',
                        close: true,
                        url: 'votePc/detail.html?pageType='+pageType
                    })
                }else if(pageType=='edit'){
                        top.closeTabByPageId("detail");
                        top.addTabs({
                            id: 'detail',
                            title: '投票详情',
                            close: true,
                            url: 'votePc/detail.html?mainId='+item+'&pageType='+pageType
                        })
                }else if(pageType=='look'){
                    top.closeTabByPageId("detail");
                    top.addTabs({
                        id: 'detail',
                        title: '投票详情',
                        close: true,
                        url: 'votePc/detail.html?mainId='+item+'&pageType='+pageType
                    })
                }else if(pageType=='shenHe'){
                    top.closeTabByPageId("detail");
                    top.addTabs({
                        id: 'detail',
                        title: '投票详情',
                        close: true,
                        url: 'votePc/detail.html?mainId='+item+'&pageType='+pageType
                    })
                }
            },
            getResult:function(mainId,auditFlag){
                var that=this;
                top.$.dialog({
                    content: 'url:votePc/result.html?mainId='+mainId+'&userId='+that.userId+'&auditFlag='+auditFlag,
                    title:"投票结果",
                    width: 650,
                    height: 600,
                    max: true,
                    min: true,
                    lock: true
                });

            },
            isCheck:function(type,item){
                var that=this;
                if(type=="修改"){
                    if(item=='-4'||item=='-3'){
                        return true;
                    } else {
                      return false;
                    }
                }
                if(type=="查看"){
                    if(item!='-4'){
                        return true;
                    } else {
                        return false;
                    }
                }
                if(type=="投票结果"){
                    if(item=='-1'||item=='0'||item=='1'||item=='2'){
                        return true;
                    } else {
                        return false;
                    }
                }
            },
            compareDate:function(d1) {
                return ((new Date(d1)) > (new Date()));
            },
            getList:function () {
                $.wyui.page.getByPage();
            },
            delete:function(id){

            },
            search: function () {
                var that=this;
                $.wyui.page.queryParams.requestPage = 1;
                $.wyui.page.queryParams.key =$.trim(that.key);
                $.wyui.page.getByPage();
            }
        },
        mounted:function (){
            var that=this;//声明一个变量指向Vue实例this，保证作用域一致
            /*$.wyui.postMethod("/vote/getUserInfoByUserId.json", {id:that.userId}, function (info) {
                that.userInfo=info.userInfo;
                console.log(that.userInfo)
            });*/
            $.wyui.postMethod(urlConfig.system.user.getUserViewById,{id:that.userId}, function (info) {
                that.userInfo=info;
                console.log(that.userInfo)
            });
            that.date = new Date().Format("hh:mm"); //修改数据date
            this.timer = setInterval(function () {
                that.date = new Date().Format("hh:mm"); //修改数据date
            }, 1000)

        }

    });
    $(function () {
        $("#txtParent").autoComplete({
            url: server.ip + urlConfig.contract.getContractBuyer,
            render: function (r, panel) {
                for (var i = 0; i < r.length; i++) {
                    $("<li></li>").data("autoComplete",
                        r[i]).html("<a>" + r[i].customerName + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + r[i].customerTel + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (r) {
                app.key = r.customerName;
                console.log(app.key)
                return false;
            },
            extraParams: {createUserId: getCurrentUser().id},
            height: 210,
            width: 300
        })

    });
    $.wyui.page.dataUrl = server.ip + "/votePage/getVoteList.json";
    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.wyui.page.queryParams = {
        userId: getCurrentUser().id,
        companyId:getCurrentUser().companyId,
        roleName:getCurrentUser().roleName,
        requestPage: 1,
        pageSize: 30,
        key:app.key
    }
    $.extend($.wyui.page.queryParams);
    $.wyui.page.getByPage_callback = function (records) {
        console.log(records)
        app.list = records;
        document.getElementById("scrollDiv").scrollTop = 0;
    };

</script>

</body>
</html>